package com.guigu.servicesystem.security.config.security.handler;


import com.guigu.servicesystem.security.model.bean.ResultJSON;
import com.guigu.servicesystem.security.utils.SecurityHandlerUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static com.guigu.servicesystem.security.utils.args.ResultArgsUtil.LOGOUT_SUCCESS_CODE;
import static com.guigu.servicesystem.security.utils.args.ResultArgsUtil.LOGOUT_SUCCESS_MSG;

/**
 * @Author xiumu
 * @Date 2020/5/28 17:14
 */
public class LogoutHandlerImpl implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        System.out.println("LogoutHandlerImpl++++++++++");
        SecurityHandlerUtil.responseHandler(httpServletResponse,new ResultJSON(LOGOUT_SUCCESS_CODE,LOGOUT_SUCCESS_MSG));
    }
}
